<?php
$this->Html->script(array('plugins/datatables/jquery.dataTables.min'), false);
?>
<?php
echo $this->Form->create('Paginate', array(
	'class' => 'validate',
	'action' => 'index',
	'url' => $this->request->here(false),
	'type' => 'post',
	'inputDefaults' => array('label' => false, 'div' => false)));
echo $this->Form->input('Paginate.task', array('style' => 'display:none;', 'value' => '', 'id' => 'task'));
echo $this->Form->hidden('calculate', array('id' => 'calculate-rank', 'value' => $this->Html->url(array(
		'action' => 'position'
))));
?>
<div class="page-header">
	<div class="icon">
		<span class="ico-layout-7"></span>
	</div>
	<h1>
		<?php echo __('KEYWORD'); ?> 
		<small><?php echo __('Dự án'); ?>
			<?php
			echo $this->Html->link($project['Project']['name'], array(
				'controller' => 'projects', 'action' => 'edit', $project['Project']['id']
			));
			?>
		</small>
	</h1>
	<div class="page-toolbar">
		<div class="btn-group ctr-container">
			<button class="btn btn-primary ctr-add" type="submit">
				<span class="ico-add"></span>
				<?php echo __('Add new'); ?>
			</button>
		</div>
	</div>
</div>

<div class="row-fluid">
	<div class="span12">
		<div class="block">
			<?php
			$continue = array(
				'?' => array('continue' => $this->request->here(false))
			);
			echo $this->Session->flash();
			?>
			<div class="data-fluid">
				<table class="table paginate lcnp" cellpadding="0" cellspacing="0" width="100%">
					<thead>
						<tr>
							<th width="20%"><?php echo __('Name'); ?></th>
							<th><?php echo __('URL'); ?></th>
							<th width="60"><?php echo __('Top Rank'); ?></th>
							<th width="60"><?php echo __('Start Rank'); ?></th>
							<th width="60"><?php echo __('Current'); ?></th>
							<th width="60"><?php echo __('Diff Rank'); ?></th>
							<th width="60"><?php echo __('Best Rank'); ?></th>
							<th width="80"><?php echo __('Ngày bắt đầu'); ?></th>
							<th width="60"><?php echo __('Thời hạn'); ?></th>
							<th width="60" class="TAC">Actions</th>
						</tr>
					</thead>
					<tbody>
						<?php foreach ($keywords as $keyword) : ?>
							<tr class="<?php echo !$keyword['Keyword']['active'] ? 'disabled' : '' ?>">
								<td>
									<?php
									echo $this->Html->link($keyword['Keyword']['name'], array(
										'action' => 'report', $keyword['Keyword']['id']
									));
									?>
								</td>
								<td>
									<?php
									echo $this->Html->link(Keyword::mainLink($keyword['Keyword']['url']), null, array(
										'target' => '_blank'
									));
									?>
								</td>
								<td>
									<span class="rank_top label label-info">
										<?php echo $keyword['Keyword']['rank_top']; ?>
									</span>
								</td>
								<td>
									<span class="rank_top label label-info">
										<?php echo $keyword['Keyword']['rank_start']; ?>
									</span>
								</td>
								<td>
									<a href="javascript:void(0);"  title="Kiểm tra rank hiện tại" class="rank_current label label-green calculate-rank" data-id="<?php echo $keyword['Keyword']['id']; ?>">
										<?php echo $keyword['Keyword']['rank_current']; ?>
									</a>
								</td>
								<td>
									<span class="rank_diff label label-info">
										<?php echo intval($keyword['Keyword']['rank_diff']); ?>
									</span>
								</td>
								<td>
									<span class="rank_best label label-info">
										<?php echo $keyword['Keyword']['rank_best']; ?>
									</span>
								</td>
								<td>
									<?php echo date('d/m/Y', strtotime($keyword['Keyword']['start_date'])); ?>
								</td>
								<td>
									<?php echo __('%s ngày', $keyword['Keyword']['expired']); ?>
								</td>
								<td class="table-action">
									<a href="<?php echo $this->Html->url($continue + array('controller' => 'keywords', 'action' => 'edit', $keyword['Keyword']['id'])); ?>" class="btn btn-mini green">
										<div class="icon"><span class="ico-pencil"></span></div>
									</a>
									<a href="<?php echo $this->Html->url($continue + array('controller' => 'keywords', 'action' => 'delete', $keyword['Keyword']['id'])); ?>" class="btn btn-mini red">
										<div class="icon"><span class="ico-remove"></span></div>
									</a>                                              
								</td>
							</tr>
						<?php endforeach; ?>                         
					</tbody>
				</table>                    
			</div> 
		</div>
	</div>
</div>
<?php echo $this->Form->end(); ?>
<style type="text/css">
	.paginate tr.disabled td,.paginate tr.disabled td a{
		color: #f00 !important;
	}
</style>